var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var Student = /** @class */ (function () {
    function Student() {
    }
    return Student;
}());
var Student_A = /** @class */ (function (_super) {
    __extends(Student_A, _super);
    function Student_A() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    // 实验前准备
    Student_A.prototype.PrepareEx = function () {
        console.log('1-学生A准备了实验器材');
    };
    // 向烧杯添加氢氧化钡溶液
    Student_A.prototype.PourReagent = function () {
        console.log('2-学生A将氢氧化钡溶液倒入烧杯');
    };
    // 向溶液中倒入二氧化碳气体
    Student_A.prototype.PourCarbon = function () {
        console.log('3-学生A将“少量”二氧化碳气体通入氢氧化钡中');
    };
    Student_A.prototype.ShowResult = function () {
        console.log('4-溶液中出现沉淀');
    };
    return Student_A;
}(Student));
var Student_B = /** @class */ (function (_super) {
    __extends(Student_B, _super);
    function Student_B() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    // 实验前准备
    Student_B.prototype.PrepareEx = function () {
        console.log('1-学生 B 准备了实验器材');
    };
    // 向烧杯添加氢氧化钡溶液
    Student_B.prototype.PourReagent = function () {
        console.log('2-学生 B 将氢氧化钡溶液倒入烧杯');
    };
    // 向溶液中倒入二氧化碳气体
    Student_B.prototype.PourCarbon = function () {
        console.log('3-学生 B 将“大量”二氧化碳气体通入氢氧化钡中');
    };
    Student_B.prototype.ShowResult = function () {
        console.log('4-溶液中出现沉淀又消失');
    };
    return Student_B;
}(Student));
/**
 * student1 缺少了步骤
 * student2 步骤顺序出错
 */
// (function () {
//   let student1: Student_A = new Student_A()
//   let student2: Student_B = new Student_B()
//   student1.PourReagent()
//   student1.PourCarbon()
//   student1.ShowResult()
//   student2.PrepareEx()
//   student2.PourCarbon()
//   student2.PourReagent()
//   student2.ShowResult()
// }())
/**
 * 抽象建造者
 */
var Teacher = /** @class */ (function () {
    function Teacher(student) {
        this.student = student;
    }
    Teacher.prototype.DirectExperiment = function () {
        this.student.PrepareEx();
        this.student.PourReagent();
        this.student.PourCarbon();
        this.student.ShowResult();
    };
    return Teacher;
}());
(function () {
    var student1 = new Student_A();
    var student2 = new Student_B();
    // 指导实验A
    var teacher = new Teacher(student1);
    teacher.DirectExperiment();
    // 指导实验A
    teacher = new Teacher(student2);
    teacher.DirectExperiment();
}());
